<template>
  <div>
    <!-- 表单部分 -->
    <wea-form @sendcity="getCityWea"></wea-form>
    <!-- 内容部分  今天天气和每小时数据-->
    <wea-content :hourly_forecast="hourly_forecast" :wea-res="weaRes" :forecast_list="forecast_list"></wea-content>
    <!-- 未来15天气 -->
    <weilai-com></weilai-com>
    <div style="margin-bottom: 600px;"></div>
  </div>
</template>

<script>
import weaForm from './wea_form.vue'
import weaContent from './wea_content.vue'
import weilaiCom from './weilai.vue'
import {getWeather} from '../../api/weather'
export default {
  name: '2209vueIndex',
  components:{
    weaForm,
    weaContent,
    weilaiCom
  },
  data() {
    return {
      nowCity:"",//当前城市
      weaRes:{},//整体的天气情况
      hourly_forecast:[],//每小时的天气情况
      forecast_list:[]//未来15天天气
    };
  },

  mounted() {
    
  },

  methods: {
    async getCityWea(city){
      this.nowCity=city;
      // city是子组件传来的城市名
      let res=await getWeather(city)
      console.log(res,"------")
      this.weaRes=res.data.result;
      this.hourly_forecast=res.data.result.hourly_forecast;
      this.forecast_list=res.data.result.forecast_list;
    }
  },
};
</script>